package fei.typhoon.engine.android;

import android.graphics.Paint;
import fei.typhoon.engine.utils.IFeiView;
import fei.typhoon.engine.utils.IOnTouchListener;
import fei.typhoon.engine.utils.ITouchListener;

public abstract class FeiSprite implements IFeiView, ITouchListener,
		IOnTouchListener {
	/** activity */
	protected FeiScreen screen = null;
	/** 基本图像绘制用的paint */
	protected Paint paint = null;
	/** 位置坐标 */
	protected float x = 0, y = 0;
	/** 缩放倍率 */
	protected float scaleX = 1.0f;
	/** 缩放倍率 */
	protected float scaleY = 1.0f;
	/** 图片变换的参考点 */
	protected float scaleOriginX = 0, scaleOriginY = 0;
	/** 旋转角度 */
	protected float rotate = 0;
	/** 图片变换的参考点 */
	protected float rotateOriginX = 0, rotateOriginY = 0;
	/** 是否可拖拽 */
	protected boolean canDrag = false;
	/** 是否被点下了 */
	protected boolean touchedDown = false;
	/** 拖拽时的点与view原点(左上角的点)X方向的距离 */
	protected float dragX = 0.0f;
	/** 拖拽时的点与view原点(左上角的点)Y方向的距离 */
	protected float dragY = 0.0f;

	public void setPaint(Paint paint) {
		this.paint = paint;
	}

	public int getWidth() {
		return 0;
	}

	public int getHeight() {

		return 0;
	}

	public void setAlpha(int alpha) {
		if (paint != null) {
			paint.setAlpha(alpha);
		}
	}

	public float getX() {
		return x;
	}

	public void setX(float x) {
		this.x = x;
	}

	public float getY() {
		return y;
	}

	public void setY(float y) {
		this.y = y;
	}

	public void setPosition(float x, float y) {
		this.x = x;
		this.y = y;
	}

	public float getScaleOriginX() {
		return scaleOriginX;
	}

	public void setScaleOriginX(float scaleOriginX) {
		this.scaleOriginX = scaleOriginX;
	}

	public float getScaleOriginY() {
		return scaleOriginY;
	}

	public void setScaleOriginY(float scaleOriginY) {
		this.scaleOriginY = scaleOriginY;
	}

	public float getRotate() {
		return rotate;
	}

	public void setRotate(float rotate) {
		this.rotate = rotate;
	}

	public float getRotateOriginX() {
		return rotateOriginX;
	}

	public void setRotateOriginX(float rotateOriginX) {
		this.rotateOriginX = rotateOriginX;
	}

	public float getRotateOriginY() {
		return rotateOriginY;
	}

	public void setRotateOriginY(float rotateOriginY) {
		this.rotateOriginY = rotateOriginY;
	}

	public float getScaleX() {
		return scaleX;
	}

	public void setScaleX(float scaleX) {
		this.scaleX = scaleX;
	}

	public float getScaleY() {
		return scaleY;
	}

	public void setScaleY(float scaleY) {
		this.scaleY = scaleY;
	}
	
	public void setSize(int width, int height){
		float scaleX = (float)width / (float)getWidth();
		float scaleY = (float)height / (float)getHeight();
		setScale(scaleX, scaleY);
	}

	public void setRotateOrigin(float rotateOriginX, float rotateOriginY) {
		setRotateOriginX(rotateOriginX);
		setRotateOriginY(rotateOriginY);
	}

	public void setScaleOrigin(float rotateOriginX, float rotateOriginY) {
		setScaleOriginX(rotateOriginX);
		setScaleOriginY(rotateOriginY);
	}

	public void setScale(float scaleX, float scaleY) {
		setScaleX(scaleX);
		setScaleY(scaleY);
	}

	public void setScale(float scale) {
		setScale(scale, scale);
	}

	public void setOrigin(float originX, float originY) {
		setRotateOrigin(originX, originY);
		setScaleOrigin(originX, originY);
	}

	// TODO 做好屏幕自适应，尤其是几何类
}
